#include <REGX52.H>
#include "Timer0.h"
#include <INTRINS.H>
#include "Key.h"

unsigned char KeyNum,LEDMode;
void main(void)
{
	P2 = 0XFE;
	Timer0_Init();
	while (1)
	{
		KeyNum = Key();
		if (KeyNum)
		{
			if (KeyNum == 1)
			{
				LEDMode++;
				if (LEDMode >= 2)
				{
					LEDMode = 0;
				}
			}
		}
		
	}
}

void Timer0_Routine(void) interrupt 1
{
	static unsigned int T0Count = 0;
	//TH0寄存器
	TH0 = 0XFC;
	//TL0寄存器
	TL0 = 0X17 + 1;
	T0Count++;
	if (T0Count >= 500)
	{
		if (LEDMode == 0)
		{
			P2 = _cror_(P2,1);
		}else{
			P2 = _crol_(P2,1);
		}
		T0Count = 0;
	}
}
